﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; 
using System.IO;
using BUS;
using DAO;

namespace CameraProjects.Admin
{
    public partial class ProductsList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtdes.Language = "vi";
                CKFinder.FileBrowser _FileBrowserNL = new CKFinder.FileBrowser();
                _FileBrowserNL.BasePath = "/ckfinder/";
                _FileBrowserNL.SetupCKEditor(txtdes);

                LoadDS();
                LoadDType();
                lblID.Text = "Tự động tăng";
            }
        } 

        private void LoadDS()
        {
            CameraBUS cBUS = new CameraBUS();
            List<Camera> list = new List<Camera>();
            list = cBUS.GetListAll();
            gvDS.DataSource = list;
            gvDS.DataBind();

        }
        private void LoadDType()
        {
            

        }
        protected void btnOK_Click(object sender, EventArgs e)
        {
            
        }

        protected void gvDS_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvDS.PageIndex = e.NewPageIndex;
            LoadDS();
        }

        protected void gvDS_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvDS.EditIndex = e.NewEditIndex;
            LoadDS();
        }

        protected void gvDS_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gvDS.EditIndex = -1;
            LoadDS();
        }

        protected void gvDS_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        { 
        }
        public void ShowMessage(string Content)
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language='javascript'>alert('" + Content + "');</script>");
        }
        protected void gvDS_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void gvDS_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Label lb1 = (Label)gvDS.Rows[e.RowIndex].FindControl("id1");
            int ma = Convert.ToInt32(lb1.Text);

            if (KiemTraOrder(ma))
            {
                ShowMessage("Đang có đơn hàng của sản phẩm này.");
            }
            else
            {
                // xóa 
            }

        }

        private bool KiemTraOrder(int ma)
        {
             
            return false;
        }
        protected void btnReset_Click(object sender, EventArgs e)
        {
            lblID.Text = "Tự động tăng";
            btnOK.Text = "Thêm";
            ResetTxt();

        }

        private void ResetTxt()
        { 
        }
    }
}